package com.shux.kafka.consumer;

import java.util.concurrent.BlockingQueue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 描述：
 * 
 * <pre>HISTORY
 * ****************************************************************************
 *  ID   DATE           PERSON          REASON
 *  1    2017年9月20日      Simba.Hua         Create
 * ****************************************************************************
 * </pre>
 * @author Simba.Hua
 */
public class QueueUtils {
	private static Logger logger = LoggerFactory.getLogger(QueueUtils.class);
	public static <V> void pushDataToQueue( V data,BlockingQueue<V> queue) {
		boolean flag = false;
		while( !flag ) {
			try {
					queue.put(data);
					flag = true;
					logger.debug("message:{} send to queue:{}",data,queue);
			} catch (InterruptedException e) {
				flag = false;
				try {
					Thread.sleep(200);
				} catch (InterruptedException e1) {
					e1.printStackTrace();
				}
			}
		}
	}
}
